package com.cd2cd.controller;

import com.cd2cd.service.SysDictItemService;
import com.cd2cd.service.SysDictService;
import com.cd2cd.vo.BaseRes;
import com.cd2cd.vo.DataPageWrapper;
import com.cd2cd.vo.SysDictItemVo;
import com.cd2cd.vo.SysDictVo;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Controller
@RequestMapping("sysDictItem")
public class SysDictItemController extends BaseController  {

    @Resource
    private SysDictItemService sysDictItemService;

    @RequestMapping( value = "list", method = RequestMethod.GET)
    @ResponseBody
    public BaseRes<DataPageWrapper<SysDictItemVo>> queryPageList(Integer currPage, Integer pageSize, SysDictItemVo sysDictItemVo) {

        return sysDictItemService.list(currPage, pageSize, sysDictItemVo);
    }

    @RequestMapping( value = "detail/{dictId}/{id}", method = RequestMethod.GET)
    @ResponseBody
    public BaseRes<SysDictItemVo> detail(@PathVariable("dictId") Integer dictId,@PathVariable("id") Integer id) {
        return sysDictItemService.detail(dictId,id);
    }

    @RequestMapping( value = "del/{dictId}/{id}", method = RequestMethod.DELETE)
    @ResponseBody
    public BaseRes<String> del(@PathVariable("dictId") Integer dictId,@PathVariable("id") Integer id) {

        return sysDictItemService.del(dictId,id);
    }

    @RequestMapping(value = "add", method = RequestMethod.POST)
    @ResponseBody
    public  BaseRes<String> add(@Validated @RequestBody SysDictItemVo sysDictItemVo, BindingResult bindingResult) {

        return sysDictItemService.add(sysDictItemVo);
    }

    @RequestMapping(value = "modify", method = RequestMethod.POST)
    @ResponseBody
    public BaseRes<String> modify(@Validated @RequestBody SysDictItemVo sysDictItemVo, BindingResult bindingResult) {

        return sysDictItemService.modify(sysDictItemVo);
    }
}
